-
Notifications
You must be signed in to change notification settings - Fork 538
fix: Add react ErrorBoundary Component to prevent app crashes from unhandled errors #958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Added a fallback UI with animated button to reload in case error vanishes. - Instead of loggin error on UI logged errors to console.
…n a crash happens
- Imported ErrorBoundary Component. - Wrapped children inside themeprovider for same theme of fallback UI. - catches rendering error in any child component.
📝 WalkthroughWalkthroughIntroduces an ErrorBoundary React component to catch and handle application errors. The component wraps the main App with fallback UI, error logging, and a retry mechanism. Integrates the boundary into the app initialization flow. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Fix all issues with AI Agents 🤖
In @frontend/src/components/ErrorBoundary/ErrorBoundary.tsx:
- Around line 34-41: The button labeled "Reload App" currently triggers a soft
reset in handleRetry (clearing hasError / error and isRetrying via setState)
which doesn't perform a full page reload; change handleRetry to perform a real
app reload by calling window.location.reload() (optionally after a short
setTimeout to show the spinner) instead of only resetting state so the button
label matches behavior and persistent child errors are cleared by a full
refresh.
🧹 Nitpick comments (1)
frontend/src/components/ErrorBoundary/ErrorBoundary.tsx (1)
25-27: Consider removing redundantisRetrying: falsefrom error state.The
isRetrying: falseassignment ingetDerivedStateFromErroris redundant since the state will either be freshly initialized (already false) or transitioning from a retry attempt (where it will be overridden anyway).🔎 Simplified implementation
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState> { - return { hasError: true, error, isRetrying: false }; + return { hasError: true, error }; }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
frontend/src/App.tsxfrontend/src/components/ErrorBoundary/ErrorBoundary.tsxfrontend/src/components/ErrorBoundary/index.ts
🔇 Additional comments (5)
frontend/src/components/ErrorBoundary/ErrorBoundary.tsx (3)
1-13: LGTM! Clean imports and well-defined interfaces.The component imports are appropriate, and the TypeScript interfaces clearly define the props and state structure for the error boundary.
29-32: LGTM! Proper error logging implementation.The error logging to console is appropriate and aligns with the PR objective to log errors without displaying them in the UI.
43-73: LGTM! Well-structured fallback UI with proper theming.The render method provides a clean, user-friendly fallback UI with appropriate theme integration. The decision to log errors to console rather than displaying them in the UI follows the stated PR objective.
frontend/src/App.tsx (1)
6-6: LGTM! ErrorBoundary is correctly integrated.The ErrorBoundary is properly placed inside
ThemeProviderand wraps all main application content, ensuring comprehensive error protection while maintaining access to the theme context for the fallback UI.Also applies to: 23-37
frontend/src/components/ErrorBoundary/index.ts (1)
1-1: LGTM! Standard barrel export pattern.The barrel export provides a clean public API for importing the ErrorBoundary component.
Hi @rahulharpal1603 here is the brief summary and related screenshots and videosfor this pr and issue.
Summary:
Added a React ErrorBoundary component to catch unhandled JavaScript errors during rendering, preventing the app from crashing to a blank white/black screen depends on the theme.
Fixes: #937
Changes Made:
Files Modified/Created:
Screenshots:
Before:
After:
Demo:
Recording.2026-01-06.010312.1.mp4
How to Test:
npm run tauri dev// Add this inside the component, before the return statement
throw new Error('Test ErrorBoundary');
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.